﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebMVC.Models.PagingViewModel>" %>
<% if(Model.CurrentPage > 1){%>
<a href="<%=WebMVC.Helpers.HtmlHelpers.AddPaging(Request.RawUrl,Model.CurrentPage - 1) %>" class="paging-previous"><<</a>
<%} else{%>
<a href="javascript:void" class="paging-previous no-paging">>></a>
<%} %>

<div class="pages-box">
<div class="pages-container">
<% if (Model.TotalPages > 1)
{ 
    int firstPage = Math.Max(1,Model.CurrentPage - 5);
    int lastPage = Math.Min(firstPage + 10, Model.TotalPages);
    
    for (int i = firstPage; i <= lastPage; i++)
{%><%if(i == Model.CurrentPage){ %><span class="paging-page-link"><%=i%></span><%}else{%><a href="<%=WebMVC.Helpers.HtmlHelpers.AddPaging(Request.RawUrl,i) %>" class="paging-page-link"><%=i %></a><%} %><%} %>
<%} %>
</div>
</div>

<% if(Model.CurrentPage < Model.TotalPages){%>
<a href="<%=WebMVC.Helpers.HtmlHelpers.AddPaging(Request.RawUrl,Model.CurrentPage + 1) %>" class="paging-next">>></a>
<%} else{%>
<a href="javascript:void" class="paging-next no-paging">>></a>
<%} %>

